package com.zs.demo.common.exception;


import com.zs.demo.common.response.CommonStatus;
import com.zs.demo.common.response.IResponseStatus;
import lombok.*;

import java.io.Serializable;

/* @Desc: 自定义异常父类
 * @author:zhengs  
 * @Time: 2018/11/20 10:08
 * @Copyright: © zhengs 版权所有  
 * @Warning: 本内容仅限于本公司内部传阅,禁止外泄或用于其它商业目的
 */
@EqualsAndHashCode(callSuper = true)
@Data
@NoArgsConstructor
public class RestException extends RuntimeException implements Serializable {
    protected Integer status;
    protected String msg;
    protected Exception e;

    public RestException(IResponseStatus statusEnum) {
        this.status = statusEnum.getStatus();
        this.msg = statusEnum.getMsg();
    }

    public RestException(IResponseStatus statusEnum, Exception e) {
        this.status = statusEnum.getStatus();
        this.msg = statusEnum.getMsg();
        this.e = e;
    }

    public RestException(String msg, Exception e) {
        this.status = CommonStatus.FAIL.status;
        this.msg = msg;
        this.e = e;
    }
}